Tooling

Mappings to 1D

class qtealeaves.tooling.HilbertCurveMap(dim, size)[source]

The map reads the input file and is organized as an ordered dictionary. The tuple of the coordinates returns the index in the 1d chain.

Arguments

The class creator takes the following arguments

diminteger

system dimensionality (1d, 2d, or 3d)

sizeint, list

Dimensionality in each spatial direction [Lx, Ly, Lz]. If only an integer is given, square or cube is assumed.

Attributes

The class attributes are now all in python indices, i.e., the dictionary keys and the index in the 1d system.

backmapping_matrix_observable(mat)[source]

We assume an n-dimensional system, e.g., n=2 for a 2d system. Takes a matrix with the index of the “flattened” over the rows and columns as input and transforms it into a 2n-dimensional tensor representing the original indices of the system.

Arguments

matnp.ndarray with rank 2.

Result to be mapped from the indices of a TTN into their original indices.

Returns

resultnp.ndarray with dimension 2n

The first n indices refer to the rows of the original data. The second n indices refer to the columns of the original data.

backmapping_vector_observable(vec)[source]

We assume an n-dimensional system, e.g., n=2 for a 2d system. Takes a vector with the index of the “flattened” as input and transforms it into a n-dimensional tensor representing the original indices of the system.

Arguments

vecnp.ndarray with rank 1

Result to be mapped from the indices of a TTN into their original indices.

Returns

resultnp.ndarray with dimension n

The first indices contain the indices of the original n-dimensional system.

calculate_size()[source]

The system is defined as an n-dimensional system, i.e., 1d, 2d or 3d. We return a tuple of length n with the system size along each dimension, which we determine from the keys. For example, for a rectangle of 8 by 4 sites, the tuple (8, 4) is returned as the lattice size.

init_1d(size)[source]

Init the Hilbert curve for a 1d system. Raises an exception. ZigZag is the only one providing a mapping for 1d.

Arguments

sizeint or list of two ints

Defines the shape of the square or rectangle.

init_2d(size)[source]

Init the Hilbert curve for a 2d system.

Arguments

sizeint or list of two ints

Defines the shape of the square or rectangle.

init_3d(size)[source]

Init the Hilbert curve for a 3d system.

Arguments

sizeint or list of two ints

Defines the shape of the square or rectangle.

show_map()[source]

It shows a matrix in which each element is the order in which the relative coordinate appears in the mapping. Defined for dim > 1.

class qtealeaves.tooling.SnakeMap(dim, size)[source]

The map follows a snake-like mapping in 2d and generalizes it for 3d.

init_2d(size)[source]

Init the snake curve for a 2d system.

Arguments

sizeint, list of two int

The size of square (int) or the size of the rectangle (list).

init_3d(size)[source]

Init the snake curve in 3d.

Arguments

sizeint, list of three int

The size of cube (int) or the size of the box (list).

class qtealeaves.tooling.ZigZagMap(dim, size)[source]

The map constructs a zig-zag mapping equal to the order of computer memory. The map loops over the smallest dimension on the innermost loop.

init_1d(size)[source]

Trivial zig-zag mapping for a 1-dimensional system.

Arguments

sizeint, list of one int

The size of chain.

init_2d(size)[source]

Zig-zag mapping for a 2-dimensional system.

Arguments

sizeint, list of two int

The size of square (int) or the size of the rectangle (list).

init_3d(size)[source]

Zig-zag mapping for a 3-dimensional system.

Arguments

sizeint, list of three int

The size of cube (int) or the size of the box (list).

class qtealeaves.tooling.map_selector(dim, size, map_type)[source]

Arguments

diminteger

system dimensionality

sizeint, list

Dimensionality in each spatial direction [Lx, Ly, Lz]. If only an integer is given, square or cube is assumed.

map_typestr

Selecting the map, either HilbertCurveMap, GeneralizedHilbertCurveMap, SnakeMap, or ZigZagMap, or an instance of HilbertCurveMap.

Lattice layout

class qtealeaves.tooling.LatticeLayout(num_x, num_y, layout_str='square')[source]

The LatticeLayout class stores the positions of the (num_x)x(num_y) grid which allows for non-square 2D lattices.

Arguments

num_xint

Number of points in x-direction.

num_yint

Number of points in y-direction

layout_strstr

Either square or triangle. Default to square

all_distances()[source]

Iterate over all sites to find the all the distances for each i,j point in the given lattice.

distance(site_a, site_b)[source]

Calculate the distance between two points.

Arguments

site_atuple of two ints or floats

Coordinates of the first site, either in the grid if integers, or in real-space coordinates if floats are passed.

site_btuple of two ints or floats

Coordinates of the second site, either in the grid if integers, or in real-space coordinates if floats are passed.

init_square()[source]

Init a square lattice with lattice spacing 1.

init_triangle()[source]

Init a hexagonal lattice with spacing 1 on all edges of the hexagons.

static iterate_sites(num_x, num_y)[source]

Iterate sites of 2D lattice layout.

Arguments

num_xint

Number of points in x-direction.

num_yint

Number of points in y-direction

unique_distances(decimals=10)[source]

Iterate over all sites to find the unique distances for the given lattice within a given decimals precision.

Arguments

decimalsint

Round the array with all the distances to the given number of decimals.

Parametrizing objects

class qtealeaves.tooling._ParameterizedClass[source]

Abstract base class for any other class which needs to evaluate parameterization.

eval_numeric_param(elem, params)[source]

Evaluate a numeric parameter which might be defined via the parameter dictionary.

Arguments

elemcallable, string, or int/float

Defines the parameter either via a function which return the value, a string being an entry in the parameter dictionary, or directly as the numeric value.

paramsdict

The parameter dictionary, which will be passed to callables and used to evaluate string parameters.

eval_param(elem, params)[source]

Evaluate a numeric, string, or typed parameter which might be defined via the parameter dictionary. While eval_numeric_param throws a key error if a string is not in the parameter dictionary, here strings (and types) are allowed as return values.

Arguments

elemcallable, string, int/float, list, or type

Defines the parameter either via a function which return the value, a string being an entry in the parameter dictionary, or directly as the numeric value.

paramsdict

The parameter dictionary, which will be passed to callables and used to evaluate string parameters.

static eval_str_param(elem, params)[source]

Evaluate a string parameter.

Arguments

elemcallable, string, or int/float

Defines the parameter either via a function which return the value, or directly as the numeric value.

paramsdict

The parameter dictionary, which will be passed to callables.

static eval_str_param_default(elem, params, default)[source]

Evaluate a string parameter and allow to set default. It sets the default as soon as elem is not callable.

Arguments

elemcallable, …

Defines the parameter via a callable. Any other variable will be overwritten by the default.

paramsdict

The parameter dictionary passed to the callable.

defaultstr

The default value if elem is not callable.

Restricted classes

class qtealeaves.tooling.restrictedclasses._RestrictedList(*args)[source]

List allowing only instances of a certain class (here object true for anything as example).

append(elem)[source]

Overwriting appending an item.

class_allowed

alias of object

extend(other)[source]

Overwriting extending a list.

insert(index, elem)[source]

Overwriting inserting an item.

Fortran interfaces

class qtealeaves.tooling.write_tensor(tensor, dest, cmplx=True, **kwargs)[source]

Write a tensor stored in a numpy matrix to a file. Conversion to column major is taken care of here.

Arguments

tensornp.ndarray

Tensor to be written to the file.

deststr, or filehandle

If string, file will be created or overwritten. If filehandle, then data will be written there.

class qtealeaves.tooling.read_tensor(file, cmplx=True, order='F')[source]

Read a tensor written in a file from fortran and store it in a numpy matrix. Conversion to row major is taken care of here if order=’F’. author: mb

Parameters

file: str, or filehandle

If string, file will be opened. If filehandle, then data will be read from there.

cmplx: bool, optional

If True the tensor is complex. Otherwise is real. Default to True.

order: str, optional

If ‘F’ the tensor is transformed from column-major to row-major, if ‘C’ it is left as read.